package com.boe.config;

import com.boe.common.base.BaseEntity;
import com.boe.common.base.BaseObjectEntity;
import com.boe.common.util.FileUtil;
import org.junit.jupiter.api.Test;

import java.io.File;


public class MyBatisPlusGeneratorEntity extends MyBatisPlusBaseTest {



    /**
     * 使用 MyBatisPlus 生成 实体
     */
    @Test
    public void mybatisGenerateEntity() {
        var javaPath = "/modules/" + moduleName + "/" + moduleName + "-entity/src/main/java";

        var entityPath = FileUtil.joinPath(currentProjectPath, javaPath, "com/boe/", moduleName, "entity");
        System.out.println("删除实体文件夹: " + entityPath);
        cn.hutool.core.io.FileUtil.del(new File(entityPath));

        generatorEntity(javaPath)
                .strategyConfig(builder -> {
                    builder
                            .addTablePrefix("s_")
                            .addInclude(
                                    "s_login_user", "s_user")
                    ;
                })
                .strategyConfig(builder -> {
                    builder.entityBuilder().superClass(BaseEntity.class);
                })
                .execute();

        generatorEntity(javaPath)
                .strategyConfig(builder -> {
                    builder
                            .addTablePrefix("dev_")
                            .addInclude(
                                    "dev_scaffold")
                    ;
                })
                .strategyConfig(builder -> {
                    builder.entityBuilder().superClass(BaseEntity.class);
                })
                .execute();


        generatorEntity(javaPath)
                .strategyConfig(builder -> {
                    builder
                            .addTablePrefix("s_")
                            .addInclude(
                                    "s_annex", "s_city")
                    ;
                })
                .strategyConfig(builder -> {
                    builder.entityBuilder().superClass(BaseObjectEntity.class);
                })
                .execute();


        generatorEntity(javaPath)
                .strategyConfig(builder -> {
                    builder
                            .addTablePrefix("dev_")
                            .addInclude(
                                    "dev_scaffold_modules")
                    ;
                })
                .strategyConfig(builder -> {
                    builder.entityBuilder().superClass(BaseObjectEntity.class);
                })
                .execute();

    }




}
